package com.itheima.oneToMany;

import com.itheima.bean.Classes;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

public class Test02 {
//    查询班级及学生

    @Test
    public void   findAll() throws Exception{
        InputStream is = Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        SqlSession sqlSession = sqlSessionFactory.openSession(true);
        ClassesMapper mapper = sqlSession.getMapper(ClassesMapper.class);
        List<Classes> classesList = mapper.findAll();

        for (int i = 0; i < classesList.size(); i++) {
            System.out.println(classesList.get(i));
        }
        sqlSession.close();
        is.close();
    }
}
